package com.hulk.dryad.activiti7.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hulk.dryad.common.annotation.PrintlnLog;
import com.hulk.dryad.common.component.R;
import com.hulk.dryad.persistence.admin.AdminUser;
import com.hulk.dryad.persistence.entity.ActivitiHighLine;
import com.hulk.dryad.persistence.service.IActivitiHistoryService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;


@Api(value = "history", tags = "历史信息模块")
@AllArgsConstructor
@RestController
@RequestMapping("/workflow/history")
public class HistoryController {

    private IActivitiHistoryService activitiHistoryService;

	@ApiOperation(value = "gethighLine", notes = "通过实例ID查询流程图高亮信息")
	@PrintlnLog
    @GetMapping("/gethighLine")
    public R gethighLine(@RequestParam("instanceId") String instanceId) {
        ActivitiHighLine activitiHighLine = activitiHistoryService.gethighLine(instanceId);
        return R.ok(activitiHighLine);
    }

	/**
	 * 用户历史
	 */
	@GetMapping(value = "/getPageHisByUserName")
	public R<IPage> getPageHisByUserName(Page page, @AuthenticationPrincipal AdminUser user) {

		IPage  ipage =	activitiHistoryService.getPageHisByUserName(page,user);
		return R.ok(ipage);
	}

	/**
	 * 任务实例历史
	 */
	@GetMapping(value = "/getPageHisByInstanceId/{instanceId}")
	public R<IPage> getPageHisByInstanceId(Page page, @PathVariable("instanceId") String instanceId) {
		IPage  ipage =	activitiHistoryService.getPageHisByInstanceId(page,instanceId);
		return R.ok(ipage);
	}
}
